package org.flashamaphone.voices
{
	import org.flashamaphone.voices.waveformFactories.IWaveFactory;
	import org.flashamaphone.voices.waveformFactories.SineWaveFactory;
	import org.flashamaphone.voices.envelope.Envelope;
	
	public class ADSRVoiceConfig extends VoiceConfig
	{
		/** attack envelope */
		public var attackEnvelope:Envelope;
		
		/** sustain envelope */
		public var sustainEnvelope:Envelope;
		
		/** decay envelope */
		public var decayEnvelope:Envelope;
		
		/** release envelope */
		public var releaseEnvelope:Envelope;
		
		
		/** attack wave generator */
		public var attackWave:IWaveFactory;
		
		/** sustain wave generator */
		public var sustainWave:IWaveFactory;
		
		/** decay wave generator */
		public var decayWave:IWaveFactory;
		
		/** release wave generator */
		public var releaseWave:IWaveFactory;
		
		
		/** decay duration (milliseconds) */
		public var decayDuration:int = 100;
		
		/** attack duration (milliseconds) */
		public var attackDuration:int = 100;
		
		/** sustain duration (milliseconds) */
		public var sustainDuration:int = -1;
		
		/** release duration (milliseconds) */
		public var releaseDuration:int = 100;
		
		
		
		/**
		 * constructor
		 *
		 * @param wavefactory
		 */
		public function ADSRVoiceConfig(wavefactory:IWaveFactory=null)
		{
			if (!wavefactory) {
				attackWave = new SineWaveFactory();
				decayWave = new SineWaveFactory();
				sustainWave = new SineWaveFactory();
				releaseWave = new SineWaveFactory();
			} else {
				attackWave = wavefactory;
				decayWave = wavefactory;
				sustainWave = wavefactory;
				releaseWave = wavefactory;
			}
			super(attackWave);
		}
	}
}